package com.mes.check.service;


import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.Expose;
import com.mes.check.dao.iface.ICheckBillDao;
import com.mes.check.domain.CheckBill;
import com.mes.check.manager.iface.ICheckBillDetailManager;
import com.mes.common.service.BasicService;
import com.mes.task.dao.iface.IOperationTaskDao;
import com.mes.task.domain.OperationTask;

@Service
public class CheckBillService extends BasicService<CheckBill> {

	@Autowired
	ICheckBillDao checkBillDao;
	@Autowired
	ICheckBillDetailManager checkBillDetailManager;
	@Autowired
	IOperationTaskDao operationTaskDao;
	
	
	/**
	 * 获取某个检验任务对应的检验单据
	 * @param checkTaskUid
	 * @return
	 * @throws Exception
	 */
	@DataProvider
	public Collection<CheckBill> getCheckBillsByCheckTaskUid(String checkTaskUid) throws Exception {
		return checkBillDao.getCheckBillsByCheckTaskUid(checkTaskUid);
	}
	
	/**
	 * 检验任务派工
	 * @param dataItems
	 * @param parameter
	 * @throws Exception
	 */
	@Expose
	public void generateCheckBillDetail(String checkBillUid, String operationTaskUid) throws Exception {
		OperationTask task = operationTaskDao.getById(operationTaskUid);
		checkBillDetailManager.generateCheckBillDetailsByOperationUid(checkBillUid, task.getOperationUid());
	}
	
	
}
